package com.auth.config.token;

import org.springframework.security.oauth2.provider.ClientDetailsService;
import org.springframework.security.oauth2.provider.OAuth2RequestFactory;
import org.springframework.security.oauth2.provider.OAuth2RequestValidator;
import org.springframework.security.oauth2.provider.TokenGranter;
import org.springframework.security.oauth2.provider.endpoint.AbstractEndpoint;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestFactory;
import org.springframework.security.oauth2.provider.request.DefaultOAuth2RequestValidator;

/**
 * 自定义获取token 配置类
 * 主要服务于自定义获取token的接口方法
 * @author: hw
 * @date: 2021/12/1 14:15
 */
public class AuthOAuth2TokenEndpoint extends AbstractEndpoint{

    private OAuth2RequestValidator oAuth2RequestValidator = new DefaultOAuth2RequestValidator();



    public OAuth2RequestValidator getoAuth2RequestValidator() {
        return oAuth2RequestValidator;
    }

    public void setoAuth2RequestValidator(OAuth2RequestValidator oAuth2RequestValidator) {
        this.oAuth2RequestValidator = oAuth2RequestValidator;
    }

    @Override
    public void setTokenGranter(TokenGranter tokenGranter) {
        super.setTokenGranter(tokenGranter);
    }

    @Override
    public TokenGranter getTokenGranter() {
        return super.getTokenGranter();
    }

    @Override
    public OAuth2RequestFactory getOAuth2RequestFactory() {
        return super.getOAuth2RequestFactory();
    }

    @Override
    public OAuth2RequestFactory getDefaultOAuth2RequestFactory() {
        return super.getDefaultOAuth2RequestFactory();
    }

    public void setOAuth2RequestFactory() {
        super.setOAuth2RequestFactory(new DefaultOAuth2RequestFactory(super.getClientDetailsService()));
    }

    @Override
    public ClientDetailsService getClientDetailsService() {
        return super.getClientDetailsService();
    }

    @Override
    public void setClientDetailsService(ClientDetailsService clientDetailsService) {
        super.setClientDetailsService(clientDetailsService);
    }
}
